from django.db import models

class ExamNumber(models.Model):
    # 考生考号模型的定义
    exam_number_field = models.CharField(max_length=20, primary_key=True)

class SubjectId(models.Model):
    # 学科id模型的定义
    subject_id_field = models.CharField(max_length=20, primary_key=True)

class TeacherId(models.Model):
    # 导师公号模型的定义
    teacher_id_field = models.CharField(max_length=20, primary_key=True)


class AuthGroup(models.Model):
    name = models.CharField(unique=True, max_length=150, db_collation='Chinese_PRC_CI_AS')

    class Meta:
        managed = False
        db_table = 'auth_group'


class AuthGroupPermissions(models.Model):
    id = models.BigAutoField(primary_key=True)
    group = models.ForeignKey(AuthGroup, models.DO_NOTHING)
    permission = models.ForeignKey('AuthPermission', models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'auth_group_permissions'
        unique_together = (('group', 'permission'),)


class AuthPermission(models.Model):
    name = models.CharField(max_length=255, db_collation='Chinese_PRC_CI_AS')
    content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING)
    codename = models.CharField(max_length=100, db_collation='Chinese_PRC_CI_AS')

    class Meta:
        managed = False
        db_table = 'auth_permission'
        unique_together = (('content_type', 'codename'),)


class AuthUser(models.Model):
    password = models.CharField(max_length=128, db_collation='Chinese_PRC_CI_AS')
    last_login = models.DateTimeField(blank=True, null=True)
    is_superuser = models.BooleanField()
    username = models.CharField(unique=True, max_length=150, db_collation='Chinese_PRC_CI_AS')
    first_name = models.CharField(max_length=150, db_collation='Chinese_PRC_CI_AS')
    last_name = models.CharField(max_length=150, db_collation='Chinese_PRC_CI_AS')
    email = models.CharField(max_length=254, db_collation='Chinese_PRC_CI_AS')
    is_staff = models.BooleanField()
    is_active = models.BooleanField()
    date_joined = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'auth_user'


class AuthUserGroups(models.Model):
    id = models.BigAutoField(primary_key=True)
    user = models.ForeignKey(AuthUser, models.DO_NOTHING)
    group = models.ForeignKey(AuthGroup, models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'auth_user_groups'
        unique_together = (('user', 'group'),)


class AuthUserUserPermissions(models.Model):
    id = models.BigAutoField(primary_key=True)
    user = models.ForeignKey(AuthUser, models.DO_NOTHING)
    permission = models.ForeignKey(AuthPermission, models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'auth_user_user_permissions'
        unique_together = (('user', 'permission'),)


class DjangoAdminLog(models.Model):
    action_time = models.DateTimeField()
    object_id = models.TextField(db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    object_repr = models.CharField(max_length=200, db_collation='Chinese_PRC_CI_AS')
    action_flag = models.SmallIntegerField()
    change_message = models.TextField(db_collation='Chinese_PRC_CI_AS')
    content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING, blank=True, null=True)
    user = models.ForeignKey(AuthUser, models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'django_admin_log'


class DjangoContentType(models.Model):
    app_label = models.CharField(max_length=100, db_collation='Chinese_PRC_CI_AS')
    model = models.CharField(max_length=100, db_collation='Chinese_PRC_CI_AS')

    class Meta:
        managed = False
        db_table = 'django_content_type'
        unique_together = (('app_label', 'model'),)


class DjangoMigrations(models.Model):
    id = models.BigAutoField(primary_key=True)
    app = models.CharField(max_length=255, db_collation='Chinese_PRC_CI_AS')
    name = models.CharField(max_length=255, db_collation='Chinese_PRC_CI_AS')
    applied = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'django_migrations'


class DjangoSession(models.Model):
    session_key = models.CharField(primary_key=True, max_length=40, db_collation='Chinese_PRC_CI_AS')
    session_data = models.TextField(db_collation='Chinese_PRC_CI_AS')
    expire_date = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'django_session'


class registration_table(models.Model):
    # 复试信息表
    examnumber = models.OneToOneField(ExamNumber, models.DO_NOTHING, db_column='examnumber', primary_key=True)
    subjectid = models.ForeignKey(SubjectId, models.DO_NOTHING, db_column='subjectid', related_name='_subjectid_set')
    subjectname = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    name = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    gender = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    undergradschool = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    undergradmajor = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    graduationtime = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    phone = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    emergencyphone = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    signature = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    stu_type = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    category = models.CharField(max_length=10, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    preferred_mentor_1 = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    preferred_mentor_2 = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    preferred_mentor_3 = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    research_direction = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    accept_adjustment = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    adjustment_order_1 = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    adjustment_order_2 = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    adjustment_order_3 = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    adjustment_order_4 = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    retesttimeplace = models.CharField(max_length=100, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    evaluation = models.TextField(db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    leadersignature = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    foreignlanguage = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    knowledgetest = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    interview = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    totalscore = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    membersignature = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    mentorsignature = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    state = models.CharField(max_length=10, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)

    class Meta:
        managed = False
        db_table = '复试登记表'


class subject_table(models.Model):
    subjectid = models.CharField(primary_key=True,max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True,)
    subjectname = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    subjectlevel = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    parentsubject = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    #parentsubject = models.ForeignKey('self', on_delete=models.SET_NULL, blank=True, null=True, related_name='children') # 外键指向自身，允许NULL
    subjectoverview = models.TextField(db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    subjecttype = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)

    class Meta:
        managed = False
        db_table = '学科信息表'


class teacher_table(models.Model):
    # 导师信息表
    instructorid = models.CharField(primary_key=True, max_length=20, db_collation='Chinese_PRC_CI_AS')
    instructorname = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructorphoto = models.BinaryField(blank=True, null=True)
    instructorbio = models.TextField(db_collation='Chinese_PRC_CI_AS', blank=True, null=True)  # This field type is a guess.
    instructoremail = models.CharField(max_length=50, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructorphone = models.CharField(max_length=11, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructorsubject = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructortype = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructortitle = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    qualification = models.CharField(max_length=10, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)

    class Meta:
        managed = False
        db_table = '导师信息表'


class enrollment_table(models.Model):
    subjectid = models.ForeignKey(SubjectId, models.DO_NOTHING, db_column='subjectid')
    subjectdirection = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructorname = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    subjectexam = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    subjectretest = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    annualquota = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    extraquota = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    year = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    eligible = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructorid = models.ForeignKey(TeacherId, models.DO_NOTHING, db_column='instructorid', related_name='_instructorid_set',primary_key=True)

    class Meta:
        managed = False
        db_table = '招生信息表'


class log(models.Model):
    # 登录信息表
    username = models.CharField(primary_key=True, max_length=20, db_collation='Chinese_PRC_CI_AS')
    password = models.CharField(max_length=128, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    userrole = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    realname = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)

    class Meta:
        managed = False
        db_table = '登录信息表'


class student_table(models.Model):
    name = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    idnumber = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    examnumber = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', primary_key=True)
    origin = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    undergradmajor = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    email = models.CharField(max_length=50, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    phone = models.CharField(max_length=11, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    undergradschool = models.CharField(max_length=50, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)

    class Meta:
        managed = False
        db_table = '考生信息表'


class firstscore_table(models.Model):
    examnumber = models.ForeignKey(ExamNumber, models.DO_NOTHING, db_column='examnumber', primary_key=True)
    englishscore = models.FloatField(blank=True, null=True)
    mathscore = models.FloatField(blank=True, null=True)
    majorscore = models.FloatField(blank=True, null=True)
    politicalscore = models.FloatField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = '考生初试成绩表'

class secondscore_table(models.Model):
    examnumber = models.ForeignKey(ExamNumber, models.DO_NOTHING, db_column='examnumber', primary_key=True)  # 修改字段名
    englishskills = models.FloatField(blank=True, null=True)
    majorknowledge = models.FloatField(blank=True, null=True)
    overallquality = models.FloatField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = '考生复试成绩表'


class student_teacher(models.Model):
    # 考生导师匹配表
    examnumber = models.ForeignKey(ExamNumber, models.DO_NOTHING, db_column='examnumber',primary_key=True)
    instructorid = models.ForeignKey(TeacherId, models.DO_NOTHING, db_column='instructorid')
    current_wish = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    status = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    
    class Meta:
        managed = False
        db_table = '考生导师匹配表'
        
class teacher_all_table(models.Model):
    instructorid = models.CharField(primary_key=True, max_length=20, db_collation='Chinese_PRC_CI_AS')
    instructorname = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructorphoto = models.BinaryField(blank=True, null=True)
    instructorbio = models.TextField(db_collation='Chinese_PRC_CI_AS', blank=True, null=True)  # This field type is a guess.
    instructoremail = models.CharField(max_length=50, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructorphone = models.CharField(max_length=11, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructorsubject = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructortype = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)
    instructortitle = models.CharField(max_length=20, db_collation='Chinese_PRC_CI_AS', blank=True, null=True)

    class Meta:
        managed = False
        db_table = '导师资格表'